<?php
namespace app\mobile\controller;
use clt\Lunar;
class Index extends Common{
    public function initialize(){
        parent::initialize();
    }
    public function index(){
		
		$ad=db('ad')->where('open=1')->limit(5)->order('sort desc')->select();
	
		
		  $this->assign('ad',$ad);
		
		$nav=db('category')
            ->where(array('parentid'=>3,'ismenu'=>1))
            ->limit(7)
            ->order('sort desc')
            ->select();
        session_start();
        $id=$_SESSION['think']['user']['id'];
        $user=getuser($id);

        $id=$_SESSION['think']['user']['id'];
        $this->assign('user',$user);
        $this->assign('nav',$nav);
        $this->assign('id',$id);
		
        return view();
    }
    //签到
    public function qiandao(){
        if (!session('user.id')) {
            // $this->redirect('user/login/index');
            $result=array('success'=>2,'msg'=>'请先登录');
            echo    json_encode($result);exit;
        }
        $id=input('post.id');
        $oauth=db('users')->where('id',$id)->value('oauth');
        if($oauth==1){
            $result=array('success'=>0,'msg'=>'今日已签到');
            echo    json_encode($result);exit;
        }else{
            $level=getulevel(1);
            //     jifen(2,$id,$level['b10'],17,1,"签到赠送");
            db('users')->where('id',$id)->setField('oauth',1);
            $result=array('success'=>1,'msg'=>'签到成功');
            echo    json_encode($result); exit;
        }

    }

}